package cn.com.wangluotongxin.linux.controller;

import cn.com.wangluotongxin.common.web.AjaxResult;
import cn.com.wangluotongxin.linux.dto.DockerDto;
import cn.com.wangluotongxin.linux.service.IDockerService;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "DOCKER")
@RestController
@RequestMapping("/docker")
public class DockerController {

    @Autowired
    private IDockerService dockerService;

    @ApiOperation("日志")
    @GetMapping("/logs")
    public AjaxResult logs(DockerDto dto) {
        Assert.isTrue(StrUtil.isNotBlank(dto.getContainerName()), "缺少容器名称");

        return AjaxResult.success(dockerService.getLogs(dto));
    }
}
